home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
3D Images
/
3D Images.iso
/
programs
/
amiga
/
catpic
/
catpic.mod
< prev
Wrap
Text File
|
1995-01-12
|
6KB
|
278 lines
MODULE CatPic5;
IMPORT Dos,
fs:FileSystem,
y:SYSTEM,
io,
NoGuru,
rq:ReqTools,
fr:FileReq,
cv:Conversions,
u:Utility,
str:Strings;
CONST
TempImag="T:TempImage";
SourceImag="T:SourceImage";
CatImag="T:CatImage" ;
EnvName="ENV:CatPic.settings";
(* cIw=800;
cIh=600;
nIx=5;
nIy=5;
*)
TYPE st=ARRAY 250 OF CHAR;
VAR fl:fs.File;
tIw:INTEGER;
tIh:INTEGER;
pNm:INTEGER;
Operator:st;
pxA,mxA:ARRAY 51 OF INTEGER;
prA,trA:ARRAY 51 OF INTEGER;
cIw,cIh,nIx,nIy,px,py:LONGINT;
Prefs,Cont:BOOLEAN;
PROCEDURE ReadPrefs;
VAR fl:fs.File;
n:INTEGER;
BEGIN;
Prefs:=FALSE;
IF fs.Open(fl,EnvName,FALSE) THEN
IF fs.ReadString(fl,Operator) THEN END;
IF fs.Read(fl,mxA) THEN END;
IF fs.Read(fl,trA) THEN END;
IF fs.Read(fl,cIw) THEN END;
IF fs.Read(fl,cIh) THEN END;
IF fs.Read(fl,nIx) THEN END;
IF fs.Read(fl,nIy) THEN Prefs:=TRUE;END;
IF fs.Close(fl) THEN END;
END;
END ReadPrefs;
PROCEDURE WritePrefs;
VAR fl:fs.File;
BEGIN;
IF fs.Open(fl,EnvName,TRUE) THEN
IF fs.WriteString(fl,Operator) THEN END;
IF fs.Write(fl,mxA) THEN END;
IF fs.Write(fl,trA) THEN END;
IF fs.Write(fl,cIw) THEN END;
IF fs.Write(fl,cIh) THEN END;
IF fs.Write(fl,nIx) THEN END;
IF fs.Write(fl,nIy) THEN END;
IF fs.Close(fl) THEN END;
END;
END WritePrefs;
PROCEDURE CustomTab;
VAR s1,s2,s3:st;
sl:ARRAY 50 OF ARRAY 5 OF CHAR;
n,m,k:INTEGER;li:LONGINT;
BEGIN;
s1:="";
FOR n:=1 TO SHORT(nIx) DO
cv.IntToStringLeft(mxA[n],s2);
str.Append(s1,s2);
IF n<nIx THEN str.Append(s1,";");END;
END;
IF rq.GetString(s1,200,"Enter Mix table",NIL,u.done) THEN
m:=1;sl[m]:="";
FOR k:=0 TO SHORT(str.Length(s1)-1) DO
IF (ORD(s1[k])>47)AND(ORD(s1[k])<58) THEN
str.AppendChar(sl[m],s1[k]);
ELSE
INC(m);sl[m]:="";
END;
END;
FOR k:=1 TO m DO IF cv.StringToInt(sl[k],li) THEN mxA[k]:=SHORT(li);END;END;
END;
s1:="";
FOR n:=1 TO SHORT(nIx) DO
cv.IntToStringLeft(trA[n],s2);
str.Append(s1,s2);
IF n<nIx THEN str.Append(s1,";");END;
END;
IF rq.GetString(s1,200,"Enter Treshold table",NIL,u.done) THEN
m:=1;sl[m]:="";
FOR k:=0 TO SHORT(str.Length(s1)-1) DO
IF (ORD(s1[k])>47)AND(ORD(s1[k])<58) THEN
str.AppendChar(sl[m],s1[k]);
ELSE
INC(m);sl[m]:="";
END;
END;
FOR k:=1 TO m DO IF cv.StringToInt(sl[k],li) THEN trA[k]:=SHORT(li);END;END;
END;
END CustomTab;
PROCEDURE InitDim;
VAR on:st;
n,m:INTEGER;
BEGIN;
cIw:=800;
cIh:=600;
nIx:=5;
nIy:=5;
Cont:=TRUE;
Operator:="$VER: Cat Builder 2.31";
Operator:="Adpro:Convolutions/";
ReadPrefs;
px:=nIx;py:=nIy;
io.WriteString("ADPro Catalog Builder by HDS\n\nOperator: ");
IF ~fr.FileReq("Select Operator",Operator) THEN Cont:=FALSE;END;
io.Write("\"");
io.WriteString(Operator);io.WriteString("\"\n");
IF Cont THEN Cont:=Cont AND rq.GetLong(nIx,"Mix Steps",NIL,rq.glMax,50,rq.glMin,2,u.done);
IF Cont THEN Cont:=Cont AND rq.GetLong(nIy,"Treshold Steps",NIL,rq.glMax,50,rq.glMin,2,u.done);
IF Cont THEN Cont:=Cont AND rq.GetLong(cIw,"CatPic Width",NIL,rq.glMax,1280,rq.glMin,320,u.done);
IF Cont THEN Cont:=Cont AND rq.GetLong(cIh,"CatPic Height",NIL,rq.glMax,1024,rq.glMin,200,u.done);
IF (~Prefs)OR(px#nIx)OR(py#nIy) THEN
FOR n:=1 TO SHORT(nIx) DO mxA[n]:=SHORT((100 DIV nIx)*n);END;
FOR n:=1 TO SHORT(nIy) DO trA[n]:=SHORT((255 DIV nIy)*n);END;
END;
IF Cont THEN IF rq.EZRequestTags("Customize table?","Yes|No",NIL,NIL,u.done)#0 THEN CustomTab;END;
tIw:=SHORT(cIw DIV nIx);
tIh:=SHORT(cIh DIV nIy);
pNm:=SHORT(nIx * nIy);
END;
END;
END;
END;
END;
WritePrefs;
END InitDim;
PROCEDURE InitRexx;
BEGIN;
IF fs.Open(fl,"T:rxfile.REXX",TRUE) THEN END;
IF fs.WriteString(fl,"/* CatPic */") THEN END;
IF fs.WriteString(fl,"ADDRESS \"ADPro\" ") THEN END;
IF fs.WriteString(fl,"OPTIONS RESULTS") THEN END;
END InitRexx;
PROCEDURE EndRexx;
BEGIN;
IF fs.Close(fl) THEN END;
IF Dos.Execute("SYS:RexxC/rx T:rxfile",NIL,NIL) THEN END;
END EndRexx;
PROCEDURE Comm(s:st);
BEGIN;
IF fs.WriteString(fl,s) THEN END;
END Comm;
PROCEDURE InitImages;
VAR s1,s2,s3:st;
BEGIN;
InitRexx;
IF cv.IntToString(tIw-1,s2,5) THEN END;
IF cv.IntToString(tIh-1,s3,5) THEN END;
s1:="ABS_SCALE ";
str.Append(s1,s2);str.Append(s1,s3);
Comm(s1);
Comm("SAVER \"TEMP\" \"XXX\" \"RAW\" ");
EndRexx;
END InitImages;
PROCEDURE InitCatPic;
VAR s1,s2,s3:st;
BEGIN;
InitRexx;
IF cv.IntToString(cIw,s2,6) THEN END;
IF cv.IntToString(cIh,s3,6) THEN END;
s1:="LOADER \"BACKDROP\" xxx COLOR ";
str.Append(s1,s2);str.Append(s1,s3);
str.Append(s1," 0 0 0 0 0 0 0 0 0 0 0 0");
Comm(s1);
EndRexx;
END InitCatPic;
PROCEDURE MakeConPics;
VAR s1,s2,s3,s4,s5:st;
n,m:INTEGER;
BEGIN;
InitRexx;
FOR n:=1 TO SHORT(nIy) DO
Comm("LOADER \"TEMP\" \"XXX\" ");
s1:="OPERATOR CONVOLVE \" ";
IF cv.IntToString(trA[n],s5,4) THEN END;
str.Append(s1,Operator);str.Append(s1,"\" 100 ");
str.Append(s1,s5);
Comm(s1);
s2:="SAVER \"IFF\" \"T:cImage.";
cv.IntToStringLeft(n,s3);
str.Append(s2,s3);
str.Append(s2,"\" \"RAW\" ");
Comm(s2);
END;
EndRexx;
END MakeConPics;
PROCEDURE PrepareCat;
VAR s1,s2,s3,s4,s5:st;
n,m:INTEGER;
BEGIN;
InitCatPic;
InitRexx;
FOR n:=1 TO SHORT(nIy) DO
FOR m:=1 TO SHORT(nIx) DO
IF cv.IntToString((m-1)*tIw,s3,5) THEN END;
IF cv.IntToString((n-1)*tIh,s4,5) THEN END;
s1:="LOADER \"TEMP\" \"XXX\" ";
str.Append(s1,s3);
str.Append(s1,s4);
str.Append(s1," 100 ");
Comm(s1);
END;
END;
EndRexx;
END PrepareCat;
PROCEDURE FillCat;
VAR s1,s2,s3,s4,s5:st;
n,m:INTEGER;
BEGIN;
InitRexx;
FOR n:=1 TO SHORT(nIy) DO
FOR m:=1 TO SHORT(nIx) DO
IF cv.IntToString((m-1)*tIw,s3,5) THEN END;
IF cv.IntToString((n-1)*tIh,s4,5) THEN END;
cv.IntToStringLeft((n),s2);
IF cv.IntToString(mxA[m],s5,5) THEN END;
s1:="LOADER \"IFF\" \"T:cImage.";
str.Append(s1,s2);
str.Append(s1,"\" ");
str.Append(s1,s3);
str.Append(s1,s4);
str.Append(s1,s5);
Comm(s1);
END;
END;
EndRexx;
END FillCat;
BEGIN;
InitDim;
IF Cont THEN
io.WriteString("Sizing...\n");
InitImages;
io.WriteString("Convolving ");io.WriteInt(nIy,2);io.WriteString(" times...\n");
MakeConPics;
io.WriteString("Preparing Catalog picture...\n");
PrepareCat;
io.WriteString("Loading ");io.WriteInt((nIy*nIx),3);
io.WriteString(" convolution pictures...\n");
FillCat;
END;
IF Dos.DeleteFile("T:SourceImage") THEN END;
IF Dos.DeleteFile("T:rxFile.REXX") THEN END;
IF Dos.Execute("Delete >NIL: T:cImage#?",NIL,NIL) THEN END;
io.WriteString("Done...\n");
END CatPic5.